package com.ms.service.module.account;

import java.text.DecimalFormat;
import java.text.NumberFormat;

import com.ms.service.module.analysis.PlatformType;
import com.xpec.c4.game.utility.GameUtility;

/**
 * deviceID綁定的體驗角色命名法
 */
public class DeviceTrialPlayerName {
	
	/**
	 * 字符轉換器(將空的位數補上0)
	 */
	private static NumberFormat formatter = new DecimalFormat("00000000000");
	
	/**
	 * 取得一個deviceID綁定的體驗角色名稱(共12位的數字)
	 */
	public static String getRandomName(PlatformType platformType){
		
		//儲值平台碼
		String platformStr = "9";//預設未定義的數字
		if(platformType != null){
			switch (platformType) {
			case ANDROID_GOOGLEPLAY:{
				platformStr = "1";
				break;
			}
			case IOS_APPSTORE:{
				platformStr = "2";
				break;
			}
			case ANDROID_OFFICAL:{
				platformStr = "3";
				break;
			}
			case WINDOWS_PC:{
				platformStr = "4";
				break;
			}
			//MAC預計使用5
			default:
				break;
			}
		}
		
		//隨機數字碼
		long ranomNum = GameUtility.randomLong(0, 99999999999L);
		String randomNumStr = formatter.format(ranomNum);
		
		//結果: 儲值平台碼(1) + 隨機數字碼(11)
		return platformStr + randomNumStr;
	}
	
}
